// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/sparepartshospital/api/SpareDashboardApi'

import InfoClass from '@api/sparepartshospital/model/SpareStockChartReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  validInfoParam(infoParam) {
    return infoParam.warehouseId
  },
  async getInfo(param, TIP = '查询信息') {
    const DTO = CORE.grpcDTO(InfoClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'querySpareStockChart', DTO)
    return resp.chart || {}
  },
  transInfo(obj, { state: { infoParam } }) {
    const { xdata = [], ydata: dataList = [] } = obj
    if (CORE.isEmpty(dataList)) return {}
    return infoParam.chartType === 3 ? { xData: xdata, dataList } : { dataList }
  },
}
